1 using UnityEngine;
2 using
System.Collections;
3
4 public
class Data {
5
6     
public static void InitData()
7     {
8         
if (!PlayerPrefs.HasKey(KEY_COIN))
9         {
10             createData();
11         }
12     }
13
14     
private static void createData()
15     {
16 #
if UNITY_EDITOR
17         PlayerPrefs.SetInt(KEY_COIN,
3000000);//GOLD
18         PlayerPrefs.SetInt(KEY_WORLD_MAP,
1);//MAP UNLOCK 1
19         
for (int i = 0; i < 4; i++)
20         {
21             PlayerPrefs.SetInt(KEY_LEVEL + i,
15);//LEVEL UNLOCK INSIDE MAP 1
22         }
23         
for (int i = 0; i < 60; i++)
24         {
25             PlayerPrefs.SetInt(KEY_STAR + i,
3);//STAR 0
26         }
27 #
else
28         PlayerPrefs.SetInt(KEY_COIN,
3000);//GOLD 3000
29          PlayerPrefs.SetInt(KEY_WORLD_MAP,
1);//MAP UNLOCK 1
30         
for (int i = 0; i < 4; i++)
31         {
32             PlayerPrefs.SetInt(KEY_LEVEL + i,
1);//LEVEL UNLOCK INSIDE MAP 1
33         }
34         
for (int i = 0; i < 60; i++)
35         {
36             PlayerPrefs.SetInt(KEY_STAR + i,
0);//STAR 0
37         }
38 #endif
39         
for (int i = 0; i < 2; i++)
40             
for (int j = 0; j < 10; j++)
41             {
42                 PlayerPrefs.SetInt(KEY_UPGRADE + i +
"" + j, 1);
43             }
44         PlayerPrefs.SetInt(KEY_ANIMAL_UNLOCK +
"0", 1);
45         
for (int i = 1; i < 10; i ++ )
46             PlayerPrefs.SetInt(KEY_ANIMAL_UNLOCK + i,
0);
47         PlayerPrefs.SetInt(KEY_GUIDE,
0);
48
49         PlayerPrefs.Save();
50     }
51
52     
public static int getData(string key)
53     {
54         
return PlayerPrefs.GetInt(key, 0);
55     }
56
57     
public static void saveData(string key, int value)
58     {
59         PlayerPrefs.SetInt(key,
value);
60     }
61
62     
public static void Save()
63     {
64         PlayerPrefs.Save();
65     }
66
67     
public const string KEY_COIN = "key_coin";
68     
public const string KEY_WORLD_MAP = "key_world_map";
69     
public const string KEY_LEVEL = "key_level";
70     
public const string KEY_STAR = "key_star";
71     
public const string KEY_ANIMAL_UNLOCK = "key_animal_unlock";
72     
public const string KEY_GUIDE = "key_guide";
73     
public const string KEY_UPGRADE = "key_upgrade";
74
75 }


PlayerPrefs.SetInt(KEY_COIN, 3000000);GOLD

PlayerPrefs.SetInt(KEY_WORLD_MAP, 1);MAP UNLOCK 1

PlayerPrefs.SetInt(KEY_LEVEL + i, 15);LEVEL UNLOCK INSIDE MAP 1

PlayerPrefs.SetInt(KEY_STAR + i, 3);STAR 0

PlayerPrefs.SetInt(KEY_COIN, 3000);GOLD 3000

PlayerPrefs.SetInt(KEY_WORLD_MAP, 1);MAP UNLOCK 1

PlayerPrefs.SetInt(KEY_LEVEL + i, 1);LEVEL UNLOCK INSIDE MAP 1

PlayerPrefs.SetInt(KEY_STAR + i, 0);STAR 0




Trò chơi đua xe động vật trong UNITY Engine 114.769 lượt xem

Gõ tìm kiếm nhanh...